<?php
namespace Home\Controller;
use Think\Controller;
use Think\Page;

/*
* 梵璞印象 & 客房中心
*/
class RoomController extends CommonController {
  private $article_model;

  public function _initialize(){
    parent::_initialize();

    $this->article_model = M('Article');
  }

  //客房中心
  public function index(){
    $template_parms = array(
      'booking' => false,
      );

    $this->restaurant(55,$template_parms);
  }

  //导航客房中心->宁心套房
  public function ningxin(){
    //booking用于控制马上订房按钮
    $template_parms = array(
      'booking' => "#41",
      'action' => 'ningxin'
      );

    $this->restaurant(41,$template_parms);
  }



  public function qingxin(){
    //booking用于控制马上订房按钮
    $template_parms = array(
      'booking' => "#42",
      'action' => __FUNCTION__
      );

    $this->restaurant(42,$template_parms);
  }

  public function jingxin(){
    //booking用于控制马上订房按钮
    $template_parms = array(
      'booking' => "#43",
      'action' => __FUNCTION__
      );

    $this->restaurant(43,$template_parms);
  }

  public function mingxin(){
    //booking用于控制马上订房按钮
    $template_parms = array(
      'booking' => "#44",
      'action' => __FUNCTION__
      );

    $this->restaurant(44,$template_parms);
  }

  public function miaoxin(){
    //booking用于控制马上订房按钮
    $template_parms = array(
      'booking' => "#41",
      'action' => 'miaoxin'
      );

    $this->restaurant(68,$template_parms);
  }

 public function shuxin(){
    //booking用于控制马上订房按钮
    $template_parms = array(
      'booking' => "#44",
      'action' => __FUNCTION__
      );

    $this->restaurant(69,$template_parms);
  }
  
  //酒店简介
  public function descrip(){
    $template_parms = array(
      'display_title' => false,
      'name' => 'descrip',
      'flag' => 'desc',
      'action' => __FUNCTION__
      );

    $this->restaurant(38,$template_parms);
  }

  //璞悦
  public function puyue(){
    $template_parms = array(
      'name' => 'restaurant',
      'action' => __FUNCTION__,
      'display_title' => true
      );

    $this->restaurant(39,$template_parms);
  }

  //璞怡
  public function puyi(){
    $template_parms = array(
      'name' => 'restaurant',
      'action' => __FUNCTION__,
       'display_title' => true
      );
    $this->restaurant(40, $template_parms);
  }


  /*通用显示简介，大厅，客房
  * @$article_id: 文章id
  * @$template_parms: 模板参数
  *   is_title:是否显示标题
  */
  private function restaurant($article_id,$template_parms){
    $article = $this->article_model->find($article_id);
    
    $article = $this->check_EN_ZH($article);

    $photo = M('Photos');
	$photolist = $photo->where('is_small=1 and photoable_id='.$article_id)->order('created_at desc')->select();
	foreach ($photolist as $k => $v ){
		$bigpath = $photo->where('id='.$v['parent_id'])->getField('path');
		$photolist[$k]['bigpath'] = $bigpath;
	}
	
	$this->assign('photo_list',$photolist);
    
    //是否显示标题 
    $template_parms['display_title'] = !$template_parms['display_title'] ? false : true;   

    if(empty($template_parms['name']))
       $template_parms['name'] = 'index';

    $this->assign('article',$article);
    $this->assign('template_parms',$template_parms);
    $this->display("Room/$template_parms[name]");
  }
}